package com.umeox.watch.moto.launcher.widget;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.ScrollView;

import com.umeox.moto.watch.themes.widget.ImageView;
import com.umeox.watch.moto.launcher.R;
import com.umeox.watch.moto.pedometer.util.CacheImpl;


public class MainTipsDialog extends Dialog {

    private static final String TAG = "MainTipsDialog";
    private Context mContext;
    private int mTipsNo;


    public MainTipsDialog(Context context, int tipsNo) {
        super(context);
        mContext = context;
        mTipsNo = tipsNo;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        int layoutRes;
        switch (mTipsNo) {
            case 2:
                layoutRes = R.layout.layout_tip2;
                break;
            case 3:
                layoutRes = R.layout.layout_tip3;
                break;
            case 4:
                layoutRes = R.layout.layout_tip4;
                break;
            case 1:
            default:
                layoutRes = R.layout.layout_tip1;

        }
        View view = LayoutInflater.from(getContext()).inflate(layoutRes, null);
        setContentView(view);

        ImageView okTv = view.findViewById(R.id.tv_ok);
        CheckBox notShowCb = view.findViewById(R.id.cb_not_show);
        ScrollView scrollView = findViewById(R.id.scrollView);

        okTv.setOnClickListener(v -> {
            if (notShowCb.isChecked()) {
                CacheImpl.getInstance().put(String.valueOf(mTipsNo), true);
            }
            dismiss();
        });


        Window window = getWindow();
        window.setGravity(Gravity.CENTER);
        window.setWindowAnimations(R.style.Animation_Uwear_Dialog_SlideVertical);
        WindowManager.LayoutParams params = window.getAttributes();
        params.height = WindowManager.LayoutParams.MATCH_PARENT;
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(params);

    }

}
